package com.example.composemodifiterdemo

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

/**
 *@author: njb
 *@date:  2023/2/8 15:43
 *@desc:
 */
class SurfaceActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            surfaceSample()
        }
    }

    @Preview
    @Composable
    fun surfaceSample() {
        Surface(
            shape = RoundedCornerShape(8.dp),
            elevation = 10.dp,
            modifier = Modifier
                .width(300.dp)
                .height(100.dp)
        ) {
            Row(modifier = Modifier.clickable {}) {
                Image(
                    painter = painterResource(id = R.mipmap.avatar),
                    contentDescription = stringResource(
                        R.string.description
                    ),
                    modifier = Modifier.size(100.dp),
                    contentScale = ContentScale.Crop
                )
                Spacer(modifier = Modifier.padding(horizontal = 12.dp))
                Column(
                    modifier = Modifier.fillMaxHeight(),
                    verticalArrangement = Arrangement.Center
                ) {
                    Text(
                        text = "Liratie",
                        style = MaterialTheme.typography.h6
                    )
                    Spacer(modifier = Modifier.padding(vertical = 8.dp))
                    Text(text = "生活就要开新~上新了!超市")
                }
            }
        }
    }
}